<%-- 
    Document   : addAssessmentItem
    Created on : Jan 11, 2012, 1:33:56 AM
    Author     : olivier
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<s:form name="form" action="/assessment/create" id="itemForm">
    <s:hidden name="idAssessment" value="%{idAssessment}"/>
    <s:hidden name="assItems.assessmentId" value="%{idAssessment}"/>
    <s:hidden name="assItems.toRange" value="%{assessment.toRange}"/>
    <s:hidden name="assItems.fromRange" value="%{assessment.fromRange}"/>
    <table> 
        <tr>
            <td class="tdLabel">Grading Item:</td>
            <td ><s:textfield id="desc" name="assItems.description" size="40"/>  </td>
        </tr>
        <tr>
            <td class="tdLabel">Item Weight:</td>
            <td><s:textfield id="weight" name="assItems.weight" size="40" value="10"/></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="Add assessment item"/>
            </td>
        </tr>
    </table>
</s:form>


<script type="text/javascript">
    
    $(function(){
        $("#itemForm").submit(function(e){
            e.preventDefault();

            dataString = $("#itemForm").serialize();

            $.ajax({
                type: "POST",
                url: "<s:url value="/assessment/addItem_%{selectedModuleCode}"/>",
                data: dataString,
                success: function(data) {
                    if (data == 'ok')
                        viewAssessment($('#itemForm_idAssessment').val());
                    else
                        $('#itemForm_idAssessment').html(data);
                    
                },
                beforeSend: function(data) {
                    $('#itemForm_idAssessment').html('<img src="<s:url value="/img/loading.gif"/>" style="padding:10px;" border="0"/>');
            
                }       
                

            });          

        });
    });
    
    
</script>

